package com.jiyun.controller;

import com.jiyun.pojo.Result;
import com.jiyun.pojo.Vehicle;
import com.jiyun.service.VehicleService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/vehicle")
public class VehicleController {
    @Autowired
    private VehicleService vehicleService;

    @Autowired
    RedisTemplate redisTemplate;
//   添加车辆信息
    @PostMapping("/addCar")
    public Result add(@RequestBody Vehicle vehicle){
        //        获取rabbitmq的队列
//        vehicle.setPicturesimage(rabbitTemplate.receiveAndConvert("imageUpload").toString());
//        rabbitTemplate.receiveAndConvert("imageUpload").toString();
        System.out.println("11111111111111111111");
        System.out.println(vehicle);
        vehicle.setPicturesimage(redisTemplate.opsForValue().get("fileUrl").toString());
        vehicleService.save(vehicle);
        return Result.success("添加成功");
    }

}
